TEMPORALS

Fighting poverty in Mexico

Area Facet

Photo by Dennis Schrader on Unsplash

Photo by Dennis Schrader on Unsplash

A darle que es mole de olla…
— Mexican Saying


Ingest

by state, year, and percentage

# Load csv data file
df <- read.csv("archetypes/fighting-poverty-in-mexico/fighting-poverty-in-mexico.csv", header = TRUE, stringsAsFactors = FALSE, encoding = "UTF-8")
df

Wrangle

wide to long

df_wrangle <- melt(df, id.vars=c("entidad"))
df_wrangle$variable <- as.integer(gsub("X", "", df_wrangle$variable))
df_wrangle

Plot

facet by state

theme_opts <- theme(
    text = element_text(family = "inconsolata", size = 10), 
    plot.title = element_text(color = "black", size = 16, face = "bold"),
    plot.subtitle = element_text(color = "black", size = 12),
    plot.caption = element_text(color = "#555555", size = 10),
    panel.border = element_blank(),
    panel.background = element_blank(),
    legend.position='none',
    panel.spacing.x = unit(1, "lines"),
    panel.spacing.y = unit(1, "lines"),
    panel.grid.minor = element_blank(),
    strip.text = element_text(size = 8.5, face = "bold"),
    strip.background = element_blank()
  )

# Plot
v1 <- 
  ggplot(df_wrangle, aes(variable, value)) +
  geom_area(fill = "#E08551") +
  geom_vline(aes(xintercept = variable), size = 0.1, color = "gray80") +
  facet_wrap( ~ entidad, scales = "free_x") +
  scale_x_continuous(breaks = seq(2008, 2018, by = 2),
                     labels = c("2008", "'10", "'12", "'14", "'16", "'18")) +
  labs(title = "Diez años de combate a la pobreza en México",
       subtitle = "Porcentaje de personas en situación de pobreza por entidad federativa",
       caption = "Fuente: CONEVAL",
       x = "Año",
       y = "Porcentaje") +
  theme_bw() +
  theme_opts

girafe(ggobj = v1, width_svg = 720/72, height_svg = 1280/72,
       options = list(opts_sizing(rescale = TRUE, width = 0.75))
)

References

citations for narrative and data sources